package com.kehutong.wwin.service.entity;

import org.coraframework.json.JSONObject;
import org.coraframework.orm.Entity;
import org.coraframework.orm.annotation.Column;
import org.coraframework.orm.annotation.Table;
import org.coraframework.orm.annotation.UnSave;
import org.coraframework.orm.util.IDType;

@Table(value="t_wwin_department", multi=true, idType=IDType.TIMESTAMP)
public class DepartmentMap extends Entity {

	private static final long serialVersionUID = -2388890134470204495L;

	protected DepartmentMap(String id) {
		super(id);
		this.sort = 30;
	}
	
	@Column(comment="客户通id")
	private String khtid;

	@Column(comment="客户通名字")
	private String khtName;
	
	@UnSave private String pid;
	@UnSave private String name;
	@UnSave private int sort;

	public String getKhtid() {
		return khtid;
	}

	public void setKhtid(String khtid) {
		this.khtid = khtid;
	}
	
	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}

	public JSONObject toWwJson() {
		JSONObject wwJson = new JSONObject();
		
		wwJson.put("id", this.id);
		wwJson.put("name", this.name);
		wwJson.put("parentid", Integer.parseInt(this.pid));
		wwJson.put("order", this.sort);
		
		return wwJson;
	}
	
	public JSONObject toKhtJson() {
		JSONObject wwJson = new JSONObject();
		
		wwJson.put("id", this.khtid);
		wwJson.put("name", this.name);
		wwJson.put("parent_id", this.pid);
		wwJson.put("sort", this.sort);
		
		return wwJson;
	}


	public String getKhtName() {
		return khtName;
	}

	public void setKhtName(String khtName) {
		this.khtName = khtName;
	}
}
